home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.0 KB | 193 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Frame.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- // ----- Framework Includes -----
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWEXTMGR_H
- #include "FWExtMgr.h"
- #endif
-
- // ----- Cyberdog Support -----
-
- #ifndef __CYBERDOG__
- #include <Cyberdog.h>
- #endif
-
- #ifndef SOM_CyberServiceMenu_xh
- #include <CyberServiceMenu.xh>
- #endif
-
- #ifndef SOM_CyberSession_xh
- #include <CyberSession.xh>
- #endif
-
- //========================================================================================
- //
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment CFrame
- #endif
-
- //========================================================================================
- // Class CFrame
- //========================================================================================
-
- FW_DEFINE_AUTO(CFrame)
-
- //----------------------------------------------------------------------------------------
- // CFrame::CFrame
- //----------------------------------------------------------------------------------------
-
- CFrame::CFrame (Environment* ev, ODFrame* odFrame, FW_CPresentation* presentation, CPart* part) :
- FW_CFrame(ev, odFrame, presentation, part),
- fPart(part)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CFrame::~CFrame
- //----------------------------------------------------------------------------------------
-
- CFrame::~CFrame()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CFrame::Draw (Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext fc (ev, this, odFacet, invalidShape);
- FW_CRect invalidRect;
- fc.GetClipRect (invalidRect);
- ::EraseRect (&fc.LogicalToDevice (invalidRect));
-
- if (!IsRoot(ev)) // draw a border to differentiate us from other parts
- FW_CRectShape::RenderRect (fc, GetBounds(ev), FW_kFrame);
-
- DrawUpdate (ev, fc);
- }
-
- //----------------------------------------------------------------------------------------
- // CFrame::DrawUpdate
- //----------------------------------------------------------------------------------------
-
- void CFrame::DrawUpdate (Environment *ev, FW_CGraphicContext & gc)
- {
- // CONTENTDATA
-
- // I call this to draw the content w/o erasing first (avoids flashiness)
- // This is useful during incremental downloads when we only need to display
- // additional content
-
- // When we're using platform graphics (as opposed to ODF's FWGraphx module) we have
- // to reset things a lot - other parts tend to leave the GrafPort in a random state.
- ::TextFont(1);
- ::TextFace(0);
- ::TextSize(0);
- ::ForeColor (blackColor);
- ::BackColor (whiteColor);
-
- FW_CRect bounds (FW_kZeroPoint, GetSize(ev));
- FW_PlatformRect pBounds = gc.LogicalToDevice (bounds);
- ::InsetRect (&pBounds, 4, 4);
- ::HLock (fPart->fDownloadedText);
- unsigned long size = GetHandleSize(fPart->fDownloadedText);
- if (size > 32767) size = 32767; // TE can't draw it, but we shouldn't truncate it
- ::TETextBox (*fPart->fDownloadedText, size, &pBounds, teFlushDefault);
- ::HUnlock (fPart->fDownloadedText);
- }
-
- //----------------------------------------------------------------------------------------
- // CFrame::FrameShapeChanged
- //----------------------------------------------------------------------------------------
-
- void CFrame::FrameShapeChanged (Environment* ev)
- {
- FW_CFrame::FrameShapeChanged (ev);
- Invalidate(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CFrame::FocusStateChanged
- //----------------------------------------------------------------------------------------
-
- void CFrame::FocusStateChanged (Environment* ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
- {
- // CYBERDOG
- if (focus == FW_CPart::fgMenuFocusToken) {
- FW_CCyberdogHelper* helper = fPart->GetCyberdogHelper();
- if (helper && helper->GetCyberServiceMenu()) {
- if (newState)
- helper->GetCyberServiceMenu()->MenuFocusAcquired (ev, GetODFrame(ev));
- else
- helper->GetCyberServiceMenu()->MenuFocusLost (ev, GetODFrame(ev));
- }
- }
-
- FW_CFrame::FocusStateChanged(ev, focus, newState, newOwner);
- }
-
- //----------------------------------------------------------------------------------------
- // CFrame::HandleWindowEvent
- //----------------------------------------------------------------------------------------
-
- FW_Handled CFrame::HandleWindowEvent (Environment* ev, const FW_CMacWindowEvent& windowEvent)
- {
- // *** Cyberdog Support ***
- // Sorry about this mess. At some point this code may be moved into
- // FW_CFrame or someplace similar. Basically we're implementing the Cyberdog
- // recipe for handling window-closing (it's different than normal OpenDoc
- // window-closing). You can just copy this code into your Frame subclass.
-
- FW_Handled handled = FW_kNotHandled;
-
- if (windowEvent.GetMessage() == inGoAway) {
- FW_CExtensionManager* manager = GetPart(ev)->GetExtensionManager(ev);
- FW_ASSERT (manager);
- ODExtension* extension = manager->AcquireExtension (ev, kCyberPartExtension, FW_kDontCreateExtension);
- if (extension) {
- CyberPartExtension* cextension = (CyberPartExtension*) extension;
- CyberSession* cyberSession = cextension->GetCyberSession (ev);
- FW_ASSERT (cyberSession);
- if (cyberSession && cyberSession->CloseCyberDraftWindow (ev, GetPart(ev)->GetODPart(ev)))
- handled = FW_kHandled;
- }
- }
-
- if (handled == FW_kNotHandled)
- handled = FW_CFrame::HandleWindowEvent (ev, windowEvent);
-
- return handled;
- }
-
-